<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'getNetworkType'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-view onekit-class="page-section">
			<onekit-view onekit-class="page-body-info">
				<onekit-view onekit-class="page-body-title">网络状态</onekit-view>
				<template v-if="hasNetworkType == false">
					<onekit-text onekit-class="page-body-text">未获取</onekit-text>
					<onekit-text onekit-class="page-body-text">点击绿色按钮可获取网络状态</onekit-text>
				</template>
				<template v-if="hasNetworkType == true">
					<onekit-text onekit-class="page-body-text-network-type">{{networkType}}</onekit-text>
				</template>
			</onekit-view>
			<onekit-view onekit-class="btn-area">
				<onekit-button type="primary" @Tap="getNetworkType">获取手机网络状态</onekit-button>
				<onekit-button @Tap="clear">清空</onekit-button>
			</onekit-view>
		</onekit-view>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "获取手机网络状态",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
export default Page(ONEKIT_JSON,["hasNetworkType","networkType"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'获取手机网络状态',
        "path":'packageAPI/pages/get-network-type/get-network-type'
};
    },
    "data":{
        "hasNetworkType":false
},
    "getNetworkType"(){
      const that = this;
      wx.getNetworkType({
        "success"(res){
          console.log(res);
          that.setData({
            "hasNetworkType":true,
            "networkType":(res.subtype) || (res.networkType)
});
        }
});
    },
    "clear"(){
      this.setData({
        "hasNetworkType":false,
        "networkType":''
});
    }
});

</script>
<style 
 lang="css">
.page-body-info {
  height: 100px ;
}
.page-body-text-network-type {
  font-size: 40px ;
  font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif ;
}
</style>